﻿@{
    ViewBag.Title = "ChaIcon";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Head{
    <title>RateIt</title>
    <link href="/Content/rate/src/rateit.css" rel="stylesheet" type="text/css">
    <link href="/Content/rate/content/bigstars.css" rel="stylesheet" type="text/css">
    <script src="/Content/rate/src/jquery.rateit.js" type="text/javascript"></script>
    <script type="text/javascript" src="@Url.Content("~/Content/js/ht_base1.js")"></script>
    <style>
        li {
            clear: both;
        }
    </style>
}
<h1>RateIt plugin</h1>
<h2>Prerequisites</h2>
<ul class="nostyle" id="examples">
    <li id="ex_a1">
        <h3>0a)显示</h3>
        <div class="rateit " data-rateit-value="2.5" data-rateit-ispreset="true"
            data-rateit-readonly="true" data-rateit-min="0" data-rateit-max="5" data-rateit-starwidth="32"
            data-rateit-starheight="32">
        </div>
    </li>

    <li id="ex_a1">
        <h3>0a)显示</h3>
        <div class="rateit antenna1" data-rateit-value="2.3" data-rateit-ispreset="true" data-rateit-step="1"
            data-rateit-readonly="true" data-rateit-min="0" data-rateit-max="5" data-rateit-starwidth="29" data-rateit-starheight="29">
        </div>
    </li>
    <li id="ex_a1">
        <h3>2a)可修改</h3>
        <input type="hidden" id="rate5_input">
        <div class="rateit bigstars fl w170" id="rate5" data-rateit-backingfld="#rate5_input"
            data-rateit-resetable="false" data-rateit-ispreset="true" data-rateit-step="1"
            data-rateit-min="0" data-rateit-max="5" data-rateit-starwidth="32" data-rateit-starheight="32">
        </div>
        <div class="fl w150 f18 lh150 mt5">
            <div id="rate5_value" class="color_yellowgreen fl" style="width: 40px">
            </div>
            &nbsp;
            <div id="rate5_op" class="fl" style="display: none">
                <a onclick="rate5_reset();return false;">重置</a>
            </div>
        </div>
        <script type="text/javascript">
            $("#rate5").bind('rated', function (event, value) {
                $('#rate5_op').show();
                $('#rate5_value').text(rate_tran1(value));
            });
            $("#rate5").bind('over', function (event, value) {
                if (!value) {
                    $('#rate5_value').text(rate_tran1($('#rate5_input').val()));
                } else {
                    $('#rate5_value').text(rate_tran1(value));
                }
            });
            $(function () {
                rate5_reset();
            });
            function rate5_reset() {
                var _defaultValue = 2;
                $('#hover5_op').hide();
                $('#rate5').rateit('value', _defaultValue);
                $('#rate5_value').text(rate_tran1(_defaultValue));
            }
        </script>
    </li>
    <hr />
    <li id="ex_a1">
        <h3>2a)可修改</h3>
        <input type="hidden" id="rate6_input">
        <div class="rateit fl w170 antenna1" id="rate6" data-rateit-backingfld="#rate6_input"
            data-rateit-resetable="false" data-rateit-ispreset="true" data-rateit-step="1"
            data-rateit-min="0" data-rateit-max="5" data-rateit-starwidth="29" data-rateit-starheight="29">
        </div>
        <div class="fl w150 f18 lh150 mt5">
            <div id="rate6_value" class="color_yellowgreen fl" style="width: 40px">
            </div>
            &nbsp;
            <div id="rate6_op" class="fl" style="display: none">
                <a onclick="rate6_reset();return false;">重置</a>
            </div>
        </div>
        <script type="text/javascript">
            $("#rate6").bind('rated', function (event, value) {
                $('#rate6_op').show();
                $('#rate6_value').text(rate_tran2(value));
            });
            $("#rate6").bind('over', function (event, value) {
                if (!value) {
                    $('#rate6_value').text(rate_tran2($('#rate6_input').val()));
                } else {
                    $('#rate6_value').text(rate_tran2(value));
                }
            });
            $(function () {
                rate6_reset();
            });
            function rate6_reset() {
                var _defaultValue = 2;
                $('#rate6_op').hide();
                $('#rate6').rateit('value', _defaultValue);
                $('#rate6_value').text(rate_tran2(_defaultValue));
            }
        </script>
    </li>
    <li id="ex_a1">
        <h3>2a)可修改</h3>
        <style type="text/css">
            .niko_rate {
            }

                .niko_rate .rateit {
                    float: left;
                    display: inline;
                    width: 135px;
                }

                .niko_rate .operate {
                    float: left;
                    display: inline;
                    font-size: 18px;
                    margin-top: 5px;
                }

                .niko_rate .operate_value {
                    color: yellowgreen;
                    line-height: 26px;
                    font-size: 17px;
                    padding-left: 4px;
                }
        </style>
        <div class="niko_rate">
            <input type="hidden" id="rate7_input" value="0" default_value="2">
            <div class="rateit antenna2" id="rate7" data-rateit-backingfld="#rate7_input"
                data-rateit-resetable="false" data-rateit-ispreset="true" data-rateit-step="1"
                data-rateit-min="0" data-rateit-max="5" data-rateit-starwidth="26" data-rateit-starheight="25">
            </div>
            <span class="operate_value fl" style=""></span>
        </div>
        <script type="text/javascript">
            $(".niko_rate .rateit").bind('rated', function (event, value) {
                console.log(1)
                var note = $(this);
                var m = note.next(".operate_value");
                if (m) {
                    var fun = eval(m.attr("transfun")) || rate_tran1;
                    m.text(fun(value));
                }
            });
            $(".niko_rate .rateit").bind('over', function (event, value) {
                console.log(1)
                var note = $(this);
                var m = note.next(".operate_value");
                if (m) {
                    var fun = eval(m.attr("transfun")) || rate_tran1;
                    if (!value) {
                        var ivalue = note.prev("input").val();
                        if (ivalue == 0) {
                            m.text("请选择");
                        } else {
                            m.text(fun(ivalue));
                        }
                    } else {
                        m.text(fun(value));
                    }
                }
            });
            function niko_rate_reset() {
                console.log(1);
                var fa = $(".niko_rate");
                if (fa) {
                    for (var i = 0; i < fa.length; i++) {
                        var note = $(fa[i]);
                        var input = note.find("input");
                        if (input && input.attr("default_value")) {
                            var value = Number(input.attr("default_value"));
                            var m = note.find(".operate_value");
                            if (m) {
                                var fun = eval(m.attr("transfun")) || rate_tran1;
                                if (!value) {
                                    m.text(fun(note.prev("input").val()));
                                } else {
                                    m.text(fun(value));
                                }
                            }
                        }
                    }
                }
            }
            $(function () {
                niko_rate_reset();
            });
        </script>
    </li>
</ul>
<!-- syntax highlighter -->
